from counterpoint.models import ForumUser
from django.shortcuts import render_to_response
from django.template import RequestContext


def render_response(req, *args, **kwargs):
    """
    Simple wrapper around render_to_response
    to make using RequestContext easier.
    """
    kwargs['context_instance'] = RequestContext(req)
    return render_to_response(*args, **kwargs)


def get_forum_user(user):
    """Retrieves the ForumUser for a given User."""
    f = None
    if user.is_authenticated():
        default_dict = {'nickname': user.username}
        f, c = ForumUser.objects.get_or_create(user=user,
                                               defaults=default_dict)
    return f
